<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var arr = ['yello','red','blue','red','orange'];
        //indexOf()方法，返回指定值在数组里的首个位置的索引，从左至右，如若数组中无该指定值，返回-1
        console.log(arr.indexOf('pink'));      
        console.log(arr.indexOf('red'));

        //lastIndexOf()方法，返回指定值在数组里的首个位置的索引，从右至左，如若数组中无该指定值，返回-1
        console.log(arr.lastIndexOf('pink'));
        console.log(arr.lastIndexOf('red'));
    </script>
</head>
<body>
    
</body>
</html>